<template>
  <Card style="height:800px">
      <p slot="title" style="color: red;font-size: large;">
        征信报告查询
      </p>
      <Row>
        <DatePicker type="date" v-model="startCreatedDate" placeholder="查询日期(起)" style="width: 200px"></DatePicker>
        <DatePicker type="date" v-model="endCreatedDate" placeholder="查询日期(止)" style="width: 200px;margin-left: 10px;"></DatePicker>
        <Input v-model="custName" style="width: 200px;margin-left: 15px;" placeholder="客户姓名"></Input>
        <Input v-model="custCardNo" style="width: 200px;margin-left: 15px;" placeholder="身份证号码"></Input>
        <Select v-model="channel" style="width:200px;margin-left: 15px;" placeholder="所属渠道">
          <Option v-for="item in channelList" :value="item.channelCode" :key="item.channelCode">{{ item.channelName }}</Option>
        </Select>
        <Select v-model="productType" style="width:200px;margin-left: 15px;" placeholder="产品名称">
          <Option v-for="item in productTypeList" :value="item.productType" :key="item.productType">{{ item.productTypeName }}</Option>
        </Select>
         <Select  placeholder="流程节点" v-model="nodeCode"   style="width:150px;margin-left: 20px;">
                  <Option v-for="item in nodeCodeList"  :value="item.nodeCode" :key="item.nodeCode">{{ item.nodeName}}</Option>
        </Select>
      </Row>
      <Row style="margin-top: 10px;">
        <Input v-model="assignee" style="width: 200px;margin-left: 15px;" placeholder="处理人"></Input>
        <!-- <Select v-model="status" style="width:200px;margin-left: 15px;" placeholder="流程状态">
          <Option v-for="item in statusList" :value="item.value" :key="item.value">{{ item.lable }}</Option>
        </Select> -->
        <Button type="primary" @click="queryPage" style="margin-left: 15px;">查询</Button>
      </Row>

      <Table stripe border :columns="columns1" :data="data1" style="margin-top: 15px;">

      </Table>

      <div class="page-box">
        <Page :total="totalNumber" size="small" :current="currentPage" :page-size="pageSize" show-total @on-change="pageIndexChange"></Page>
      </div>
  </Card>
</template>
<script>
export default {
  data () {
    return {
      $ajax: null,

      path: this.$route.path,

      totalNumber: 1, // 总记录数

      currentPage: 1, // 当前页码

      pageSize: 20, // 页大小

      startCreatedDate: null,

      endCreatedDate: null,

      custCardNo: null,
      nodeCode: null,
      channel: null,
      channelList: [],
      custName: null,
      productType: null,
      productTypeList: [],
      assignee: null,
      curNodeCode: null,
      caseStatus: null,
      status: null,
      nodeCodeList: [],
      statusList: [
        {
          lable: '草稿',
          value: '1'
        },
        {
          lable: '处理中',
          value: '0'
        },
        {
          lable: '正常结案',
          value: '2'
        },
        {
          lable: '异常结案',
          value: '3'
        },
        {
          lable: '挂起',
          value: '9'
        }
      ],
      // 序号、客户姓名、身份证号码、贷款名称、所属渠道、客户经理、提交日期、处理人（中文）、流程状态（处理、上传、审核、否决、退回、补件重审）；
      columns1: [{
        align: 'center',
        type: 'index',
        width: 60,
        title: '序号'
      },
      {
        align: 'center',
        title: '客户姓名',
        key: 'custName'
      },
      {
        align: 'center',
        title: '进件号',
        key: 'loanId'
      },
      {
        align: 'center',
        title: '身份证号码',
        key: 'custCardNo'
      },
      {
        align: 'center',
        title: '贷款名称',
        key: 'productTypeName'
      },
      {
        align: 'center',
        title: '所属渠道',
        key: 'channelName'
      },
      {
        align: 'center',
        title: '客户经理',
        key: 'employeeName'
      },
      {
        align: 'center',
        title: '提交日期',
        key: 'createdDate',
        render: (h, params) => {
          var vm = this
          return h('div', [
            h('span', vm.$util.formatTime(params.row.createdDate))
          ])
        }
      },
      // {
      //   align: 'center',
      //   title: '流程状态',
      //   key: 'statusName'
      // },
      {
        align: 'center',
        title: '处理人',
        key: 'assigneeName'
      }
      ],
      data1: []

    }
  },

  methods: {
    pageIndexChange (pageIndex) {
      this.currentPage = pageIndex
      this.queryPage()
    },

    initPage () {
      let vm = this
      vm.$ajax.post(vm.$appContext.marvels_core_product + '/product/mcpt/service/searchChannel', {}).then(re => {
        vm.channelList = re.data.data
      }).catch(er => {
      })
      vm.$ajax.post(vm.$appContext.marvels_core_product + '/product/api/mcptProductTypeInfo', {}).then(re => {
        // console.log(re.data)
        vm.productTypeList = re.data
      }).catch(er => {
      })
      vm.$ajax.post(this.$appContext.marvels_core_approve + 'approve/approvalManagement/approvalProcess/service/screeneCondition').then(re => {
        var data = re.data
        vm.nodeCodeList.push({ nodeCode: '', nodeName: '请选择' })
        for (var nodeCodeLength = 0; nodeCodeLength < data.data.nodeList.length; nodeCodeLength++) {
          vm.nodeCodeList.push(data.data.nodeList[nodeCodeLength])
        }
      }).catch(er => {

      })
      this.queryPage()
    },

    queryPage () {
      const vm = this
      var params = {
        pageNum: vm.currentPage,
        pageSize: vm.pageSize,
        custCardNo: vm.custCardNo,
        channel: vm.channel,
        custName: vm.custName,
        startCreatedDate: vm.startCreatedDate,
        endCreatedDate: vm.endCreatedDate,
        productType: vm.productType,
        assignee: vm.assignee,
        // curNodeCode:vm.curNodeCode,
        // curNodeCodes: [],
        status: vm.status,
        curNodeCode: vm.nodeCode
      }
      // params.curNodeCodes.push(vm.curNodeCode)
      vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/queryCreditList', params).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        // console.log(data)
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.data1 = re.data.data.list
        let lent = vm.data1.length
        for (let i = 0; i < lent; i++) {
          var ss = vm.data1[i].status
          // 1 草稿，0 处理中，2 正常结案，3 异常结案，9 挂起',
          if (ss === 1) {
            vm.data1[i].statusName = '草稿'
          } else if (ss === 0) {
            vm.data1[i].statusName = '处理中'
          } else if (ss === 2) {
            vm.data1[i].statusName = '正常结案'
          } else if (ss === 3) {
            vm.data1[i].statusName = '异常结案'
          } else if (ss === 9) {
            vm.data1[i].statusName = '挂起'
          }
        }
        vm.totalNumber = re.data.data.total
      }).catch(er => {

      })
    }

  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.initPage()
  }
}
</script>

<style lang="less">
@import '../../../styles/common.less';
@import '../../../styles/table.less';
</style>
